#include "RoleManager.h"

RoleManager::RoleManager()
{
	//ctor
}

RoleManager::~RoleManager()
{
	//dtor
}

// 获取角色数据
Role* RoleManager::GetRole(int _roleId)
{
	if(m_DataMap.count(_roleId) != 0)
	{
		return &m_DataMap[_roleId];
	}

	Debug::Error(__func__, "() error. not found. id:", _roleId);
	return nullptr;
}

bool RoleManager::UpdateRole(const Role& _Role)
{
	int roleId = _Role.m_oid;
	Role* pRole = GetRole(roleId);
	if(pRole != nullptr)
	{
		pRole->m_lv = _Role.m_lv;
		pRole->m_exp = _Role.m_exp;

		pRole->m_hp = _Role.m_hp;
		pRole->m_countryId = _Role.m_countryId;
		pRole->m_cityId = _Role.m_cityId;
		pRole->m_buildId = _Role.m_buildId;
		pRole->m_jobId = _Role.m_jobId;

		pRole->m_houseId = _Role.m_houseId;

		return true;
	}

	m_DataMap[_Role.m_oid] = _Role;
	return true;
}
